package com.cps.match.xmlparser;

import com.cps.match.sdo.PrincipalMatch;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

public class ConvertPrincipleMatch implements Converter{

	@SuppressWarnings("rawtypes")
	@Override
	public boolean canConvert(Class arg0) {
		return arg0.equals(PrincipalMatch.class);
	}

	@Override
	public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext ctx) {
		
	}

	@Override
	public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext ctx) {
		PrincipalMatch principleMatch = new PrincipalMatch();
		while (reader.hasMoreChildren()) {
			reader.moveDown();
			MatchValueHelper.assignValue(principleMatch, reader.getNodeName(), reader.getValue());
			reader.moveUp();
		}
		return principleMatch;
		
	}

}
